﻿using System.IO;
using System.ServiceModel.Syndication;
using NUnit.Framework;
using OpenWaves.Caching;
using OpenWaves.Syndication;

namespace OpenWaves.UnitTests.Syndication
{
    [TestFixture]
    public class FeedAggregationServiceTests
    {
        [Test]
        public void Test()
        {
            var memoryStream = new MemoryStream();

            var expectedFeed = new SyndicationFeed {Title = new TextSyndicationContent("Expected")};

            FeedAggregationServiceFactory.SerializeCacheEntry(new MultilevelCacheEntry<AsyncCacheEntry<SyndicationFeed>>(new AsyncCacheEntry<SyndicationFeed>(expectedFeed)), memoryStream);

            memoryStream.Seek(0, SeekOrigin.Begin);

            var actualFeed = FeedAggregationServiceFactory.DeserializeCacheEntry(memoryStream);

            Assert.That(actualFeed.Value.Value.Title.Text, Is.EqualTo("Expected"));
        }
    }
}